// Copyright 2015 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package mixins

import (
	"github.com/wrzfeijianshen/gxui/gxui/gxuiwidgets"
)

type SuggestionAdapter struct {
	gxuiwidgets.FilteredListAdapter
}

func (a *SuggestionAdapter) SetSuggestions(suggestions []gxuiwidgets.CodeSuggestion) {
	items := make([]gxuiwidgets.FilteredListItem, len(suggestions))
	for i, s := range suggestions {
		items[i].Name = s.Name()
		items[i].Data = s
	}
	a.SetItems(items)
}

func (a *SuggestionAdapter) Suggestion(item gxuiwidgets.AdapterItem) gxuiwidgets.CodeSuggestion {
	return item.(gxuiwidgets.FilteredListItem).Data.(gxuiwidgets.CodeSuggestion)
}
